package com.tueye.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.tueye.base.util.BaseService;
import com.tueye.base.util.IBaseHbnDao;
import com.tueye.base.util.Page;
import com.tueye.dao.IArticleDao;
import com.tueye.entity.ArticleTopic;
import com.tueye.service.IArticleService;
import com.tueye.service.exception.TuEyeServiceException;

@Scope("prototype")
@Component("articleService")
public class ArticleServiceImpl extends BaseService implements IArticleService{
	
	@Autowired
	@Qualifier("articleDao")
	private IArticleDao articleDao;
	
	@Autowired
	@Qualifier("baseHbnDao")
	private IBaseHbnDao  baseHbnDao;
	
	@Override
	public Page pagedQueryByHQL(String hql, int pageNo, int pageSize,
			Object... values)throws TuEyeServiceException {
		return articleDao.pagedQueryByHQL(hql, pageNo, pageSize, values);
	}

	@Override
	public void addArticle(ArticleTopic article) throws TuEyeServiceException {
		// TODO Auto-generated method stub
		articleDao.addArticle(article);
	}

	@Override
	public ArticleTopic getArticleById(String id) throws TuEyeServiceException {
		// TODO Auto-generated method stub
		return articleDao.getArticleById(id);
	}

	@Override
	public void delArticle(String id) throws TuEyeServiceException {
		// TODO Auto-generated method stub
		 articleDao.delArticle(id);
	}

	@Override
	public List<Object[]> getArticleTopicByTopic(String topicId)
			throws TuEyeServiceException {
		// TODO Auto-generated method stub
		 List<Object[]> result = this.baseHbnDao.queryList("select u.id,u.articleTpTitle from ArticleTopic u  where u.topicType.id='"+topicId+"'");
		return result;
	}
    

	

	
}
